const app = getApp();
Component({
  //数据
  data: {
    selected: 0,//当前tabBar页面
    color: "#999999",//未选中tabBar时的文字颜色
    selectedColor: "#3B83FC",//选中时tabBar文字颜色
    // tabBar对象集合
    list: [
      {
        pagePath: "/pages/index/index",
        text: "发票",
        iconPath: "/pages/resource/icon/navigation_index.png",
        selectedIconPath: "/pages/resource/icon/navigation_index_on.png"
      },
      {
        pagePath: "/pages/mine/mine",
        text: "我的",
        iconPath: "/pages/resource/icon/navigation_mine.png",
        selectedIconPath: "/pages/resource/icon/navigation_mine_on.png"
      }
    ]
  },
  onLoad: function () {
    console.log("----------------tab onload--------------")
  },
  methods: {
    // tabBar切换事件
    switchTab(e) {
      var that = this
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({url})
      that.setData({
        selected: data.index
      })
    }
  }
})